from rest_framework.generics import GenericAPIView

from gesture_calculation.gesture_algorithm.gesture_comparing_tool import gesture_comparing
from threedGestureProject.common.result import BaseResponse


class GestureApi(GenericAPIView):

    @staticmethod
    def post(request):
        files = request.FILES.getlist('images')
        result = gesture_comparing(files)
        part = [item for item in result.keys()][0]
        if result.get(part) >= 0.5:
            return BaseResponse(message=f'{part}不标准')
        else:
            return BaseResponse(message='动作标准')
